import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJjD5SIJ+S8RcRvQ20tXa9xSGEiYjPawRMTfAE9RjTNikZ6l9kccm1OHcDROXR2SFcs9SEY4FmxeHaWYc8xuR2ECAwEAAQ=='

const privateKey = 'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAmMPlIgn5LxFxG9DbS1dr3FIYSJiM9rBExN8AT1GNM2KRnqX2RxybU4dwNE5dHZIVyz1IRjgWbF4dpZhzzG5HYQIDAQABAkAeMqMpvmT2q/D6+adP1mEo9UV9nEJJRYDild5+z3UlEeg949oZ0Sq/sxBIAur8qO7sQLO2PwmiweaSiGPaOEJtAiEA8mfe/4vCrELPF9KFXF8LVVKjQqT9A3zvP51YXCbazMcCIQChVRaZgeHB/mfXKksMVRW1hR4acFkDhqa0XjreMLqSlwIgRvUA4e0XXzVvSZnmT9PCjYdTIv8I0SyRHB4C73awNaECIAsf2eIV4aJFz5U3llswVsHgfvXlv02N8FrJkJeXlpXbAiEAnkaRdWeGIDsBf2VcdxexYr6p5m8hVoooLSvCq/8ljlE='

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}
